package com.zb.listener;

import javax.servlet.ServletContextEvent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.ContextLoaderListener;

import com.zb.init.InitAccountCache;
import com.zb.init.InitTask;

public class UmeiContextListener extends ContextLoaderListener {

    private static final Logger logger = LoggerFactory
            .getLogger(UmeiContextListener.class);

    /**
     * spring容器启动的时候需要做的事情 TODO 简单描述该方法的实现功能（可选）.
     * 
     * @see org.springframework.web.context.ContextLoaderListener#contextInitialized(javax.servlet.ServletContextEvent)
     */
    @Override
    public void contextInitialized(ServletContextEvent event) {
        try {
            super.contextInitialized(event);

            // 加载码表到缓存
            InitAccountCache process4AccountCache = new InitAccountCache();
            process4AccountCache.onApplicationEvent();

            // 启动任务调度
            InitTask initTask = new InitTask();
            initTask.onApplicationEvent();

        } catch (Exception e) {
            logger.error("", e);
        }
    }
}